package com.magina.project.mgdb.listencer;

import com.google.common.eventbus.Subscribe;
import com.magina.project.mgdb.event.DemoEvent1;
import com.magina.project.mgdb.event.DemoEvent2;
import org.springframework.stereotype.Component;

/**
 * @ClassnName :com.magina.project.mgdb.listencer.MaginaListener
 * @Author： Magina.Hu
 * @Date： 2019/5/6
 * @Description：
 * @Version: V1.0
 * Copyright (c) 2019-2020 .All rights reserved.
 */
@Component
public class MaginaListener {
    @Subscribe
    public void subscribeDemoEvent1(DemoEvent1 event){
        System.out.println(String.format("method 1 : receive Demo event;name1=%s,code1=%s", event.getName1(),event.getCode1()));
    }

    @Subscribe
    public void subscribeDemoEvent2(DemoEvent2 event){
        System.out.println(String.format("method 2 : receive Demo event;name2=%s,code2=%s", event.getName2(),event.getCode2()));
    }

    @Subscribe
    public void subscribeRegisterEvent(DemoEvent1 event){
        try{
            Thread.sleep(3000L);
        }catch (Exception exp){
            exp.printStackTrace();
        }
        System.out.println(String.format("method 1Th  : receive register event;name1=%s,code1=%s", event.getName1(),event.getCode1()));

    }
}
